@extends('admin.base')
@section('title', '分类列表')
@section('content')
    <div class="layui-card">
        <fieldset class="layui-elem-field">
            <div class="layui-field-box">
                <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
                <span class="layui-btn-sm">分类列表</span>
            </div>
        </fieldset>
        <div class="layui-card-header">
            <div>
        <span class="pull-left">
          <div class="layui-form">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">关键字</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="sub_keywords" name="keywords" value="{{ isset($keywords) ? $keywords : '' }}"  placeholder="分类名">
                </div>
                  <label class="layui-form-label">分类</label>
                  <div class="layui-form layui-input-inline" lay-filter="test2" >
                    <select id="sub_pid" name="pid" lay-verify="" lay-search >
                            <option value="">==请选择==</option>
                        @foreach($all_list as $fvo)
                            <option value="{{$fvo->tid}}" @if($pid == $fvo->tid) selected @endif><?php echo str_repeat("&nbsp;",substr_count($fvo->path,',')*3);?>|--{{$fvo->name}}</option>
                        @endforeach
                    </select>
                </div>
              </div>
            </div>
          </div>
        </span>
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="selectsub">搜索</button>
            <!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="exportsub" ></i>导出</button>  -->
        </div>

            <span class="pull-right">
                {{--<button class="layui-btn layui-btn-sm" onclick="active('{{url('admin/type/add')}}','','添加根分类');" >--}}
                    {{--<i class="layui-icon">&#xe608;</i> 添加根分类--}}
                {{--</button>--}}
            </span>
            </div>
        </div>

        <div class="layui-card-body">
            <style>
                table tr td.tc,table tr th.tc {
                    text-align: center;
                    cursor:default;
                }
            </style>
            <table class="layui-table" lay-even lay-size="">
                <colgroup>
                    <col width="">
                    <col width="">
                    <col width="">
                    <col width="">
                </colgroup>
                <thead>
                <tr>
                    <th class="tc">ID</th>
                    <th class="tc">货源分类ID</th>
                    <th class="tc">分类名</th>
                    {{--<th class="tc">图片</th>--}}
                    <th class="tc">路径</th>
                    {{--<th class="tc">操作</th>--}}
                </tr>
                <tbody>
                @if($list->isEmpty())
                    <tr>
                        <td colspan="6" class="tc">暂无数据</td>
                    </tr>
                @else
                    @foreach ($list as $v)
                        <tr>
                            <td class="tc">{{$v->id}}</td>
                            <td class="tc">{{$v->tid}}</td>
                            <td><?php echo str_repeat("&nbsp;",substr_count($v->path,',')*3);?>|--{{$v->name}}</td>
                            {{--<td class="tc"><img src="{{$v->picpath}}{{ $v->picname }}"></td>--}}
                            <td class="tc">{{ $v->path }}</td>
                        {{--<td class="tc">--}}
                            {{--<div class="layui-btn-group" >--}}
{{--                                <button class="layui-btn layui-btn-sm" onclick="active('{{url('admin/type/edit')}}','{{$v->id}}','编辑');" >编辑</button>--}}
{{--                                <button class="layui-btn layui-btn-sm" onclick="active('{{url('admin/type/add_son')}}','{{$v->id}}','编辑');" >添加子类</button>--}}
{{--                                @if($v->exit == 2)--}}
                                    {{--<button class="layui-btn layui-btn-sm layui-btn-danger" onclick="del('{{url('admin/type/del')}}','{{$v->id}}');" >删除</button>--}}
                                {{--@endif--}}
<!--                                --><?php //?>
                            {{--</div>--}}
                        </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                </thead>
            </table>
            <!-- 分页 -->
            <div class="sabrosus" >{{ $page }}</div>
        <!-- {{$list->total()}} -->
        </div>

    </div>
@endsection
@section('js')
    <script>
        layui.use('form', function(){
            var form = layui.form;

            //搜索
            form.on('submit(selectsub)', function(data){
                let keywords = $('#sub_keywords').val();//关键字
                let pid = $("#sub_pid option:selected").val();//级别
                // layer.msg(keywords+"|"+month+"|"+level)
                location.href = "{{url('admin/type/index')}}"+"?keywords="+keywords+"&pid="+pid;
                return false;
            });

            //监听指定开关
            form.on('switch(switchTest)', function(data){
                var id = data.value;

                if(data.elem.checked){
                    var state = 1;//启用
                }else{
                    var state = 2;//禁用
                }
                ajax('/admin/user/up_state',{id:id,state:state});
            });
        });
    </script>
@endsection